home *** CD-ROM | disk | FTP | other *** search
- ;void save_box_b(box,top_x,top_y,width,depth);
- ; unsigned char *box,top_x,top_y,width,depth;
-
- EXTRN _memory_model:byte
- EXTRN _video_page:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _save_box_b
- _save_box_b proc near
- cld ;set direction flag
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov bh,_video_page ;set page number
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- les di,dword ptr[bp+4] ;ES:DI pts to byte array
- inc bp ;inc BP since dword ptr
- inc bp ;
- jmp short L00 ;
- L0: mov ax,ds ;shift DS to ES
- mov es,ax ;
- mov di,[bp+4] ;NEAR case
- L00: mov dl,[bp+6] ;topleft column in DL
- dec dl ;count from 0
- mov dh,[bp+8] ;topleft row in DH
- dec dh ;count from 0
- mov al,[bp+10] ;width in AL
- dec al ;dec for test
- cmp al,79 ;in range?
- ja L4 ;quit if not
- inc al ;readjust
- mov ah,[bp+12] ;depth in AH
- dec ah ;dec for test
- cmp ah,24 ;in range?
- ja L4 ;quit if not
- inc ah ;readjust
- mov bp,ax ;copy in BP
- sub cx,cx ;clear CX
- mov cl,al ;copy width into CX
- mov si,cx ;move to SI as counter
- mov ah,2 ;function to set cursor
- int 10h ;set the cursor
- push dx ;save start-of-row pos
- L1: mov ah,8 ;func to read char-attri
- int 10h ;read the char and attri
- stosw ;write to the save area
- dec si ;decrement width counter
- jz L3 ;to next row if last col
- inc dl ;incre cursor col
- L2: mov ah,2 ;function to set cursor
- int 10h ;reset the cursor
- jmp short L1 ;go do next character
- L3: pop dx ;new row: get old pos
- mov cx,bp ;width-depth to CX
- dec ch ;decre depth counter
- jz L4 ;quit if finished
- mov bp,cx ;resave depth-width
- sub ch,ch ;CX = width
- mov si,cx ;transfer to SI as ctr
- inc dh ;increase row number
- push dx ;save for next time
- jmp short L2 ;go set new cursor pos
- L4: pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _save_box_b endp
- _TEXT ENDS
- END